<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">

<ui:composition template="/layouts/template.xhtml">
	<ui:define name="body">
		<h:form id="form" acceptcharset="ISO-8859-1">
			<f:metadata>
				<f:viewParam name="param" value="#{permissionBean.param}"/>
			</f:metadata>

			<p:panel header="#{msgs['massai.user.header.consult']}">
				<fieldset>
					<legend>
						<h:outputText value="#{msgs['massai.permission.userData']}" />
					</legend>
					<h:panelGrid columns="3">
						<h:panelGrid>
							<p:outputLabel value="#{msgs['massai.permission.login']}" for="login" />
							<p:inputText id="login" tabindex="2" maxlength="20" disabled="true" readonly="true"
								value="#{permissionBean.user.username}" style="width: 110px;" />
						</h:panelGrid>

						<h:panelGrid>
							<p:outputLabel value="#{msgs['massai.permission.name']}" for="name" />
							<p:inputText id="name" tabindex="3" value="#{permissionBean.user.nameCollaborator}"
								style="width: 250px;" maxlength="150" disabled="true" readonly="true" />
						</h:panelGrid>
						
						<h:panelGrid columns="2" style="padding: 18px 10px 0 10px;">
							<p:selectBooleanCheckbox tabindex="1" 
								value="#{permissionBean.administrator}" id="admin" label="#{msgs['massai.permission.administrator']}">
								<p:ajax event="change" update="form" />
							</p:selectBooleanCheckbox>
							<h:outputLabel value="#{msgs['massai.permission.administrator']}" />
						</h:panelGrid>
					</h:panelGrid>
				</fieldset>

				<h:panelGroup rendered="#{!permissionBean.administrator}" id="panelFunctionality">
					<p:spacer height="20px" />

					<h:panelGrid>
						<p:tree value="#{permissionBean.treeRoot}" var="permissions" selectionMode="checkbox"
							animate="true" propagateSelectionDown="true" propagateSelectionUp="true" style="margin-top: 30px;"
							selection="#{permissionBean.nodesSelectedTrees}">
							<p:treeNode icon="ui-icon-gear">
								<h:outputText value="#{permissions}"/>
							</p:treeNode>
							<p:treeNode type="document" icon="ui-icon ui-icon-document">
								<h:outputText value="#{permissions.nameAction}" />
							</p:treeNode>
						</p:tree>
					</h:panelGrid>
				</h:panelGroup>

				<p:spacer height="20px" />

				<h:panelGrid style="width: 100%;">
					<h:panelGrid style="float: right;" columns="2">
						<p:commandButton value="#{msgs['common.back']}" style="padding: 1px !important;"
							action="permissionConsult" ajax="false" immediate="true" tabindex="5" />

						<p:commandButton tabindex="6" value="#{msgs['common.save']}"
							actionListener="#{permissionBean.save()}" ajax="false" 
							style="margin-right: 5px;" styleClass="buttonSave" update=":form"
							rendered="#{sessionBean.showAction('adminPermission', 'update')}" />
					</h:panelGrid>
				</h:panelGrid>
			</p:panel>
		</h:form>
	</ui:define>
</ui:composition>
</html>